package com.example.controller;


import com.example.pojo.Sport;
import org.springframework.web.bind.annotation.PathVariable;
import com.example.service.ISportService;
import com.example.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/sports")
@Api(tags = "运动api接口")
public class SportController {

    @Autowired
    private ISportService sportService;

    @ApiOperation("查询全部")
    @GetMapping("/all")
    public R<List<Sport>> getAllSports() {
        return R.success("成功", sportService.getAllSports());
    }

    @ApiOperation("查询单个")
    @GetMapping("/{sportId}")
    public R<List<Sport>> getSportById(@PathVariable("sportId") Long sportId) {
        return R.success("成功", sportService.getSportById(sportId));
    }



}
